package com.lfx.concurrent;

import java.util.Random;

public class ChangeThread extends Thread{

    private final Data data;

    private final Random random=new Random();


    public ChangeThread(Data data,String name) {
        super(name);
        this.data = data;
    }

    @Override
    public void run() {
        for (int i = 0;true; i++) {
            data.change("第"+i+"修改内容");
            try {
                Thread.sleep(random.nextInt(2000));
                data.save();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
